package com.ez.supervise.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ez.supervise.core.Page;
import com.ez.supervise.dao.GoalCategoryDao;
import com.ez.supervise.dao.base.BaseDaoImpl;
import com.ez.supervise.model.biz.GoalCategory;

public class GoalCategoryDaoImpl extends BaseDaoImpl implements GoalCategoryDao {

    public void insert(Object goalcategory) {
	sqlMapClientTemplate.insert("biz.insertGoalCategory", goalcategory);
    }

    public Object get(Long id) {
	return (GoalCategory) sqlMapClientTemplate.queryForObject("biz.getGoalCategoryById", id);
    }

    public void update(Object org) {
	sqlMapClientTemplate.update("biz.updateGoalCategory", org);
    }

    public void delete(Long id) {
	sqlMapClientTemplate.update("biz.deleteGoalCategory", id);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.GoalCategoryDao#findByCount(com.ez.supervise.core.Page)
     */
    public int findByCount(Page page) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.findGoalCategoryByCount", page);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.GoalCategoryDao#findByPage(com.ez.supervise.core.Page)
     */
    public List findByPage(Page page) {
	return getSqlMapClientTemplate().queryForList("biz.findGoalCategoryByPage", page);
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.ez.supervise.dao.GoalCategoryDao#findAll()
     */
    public List findAll() {
	return getSqlMapClientTemplate().queryForList("biz.findAllGoalCategory");
    }

    /* (non-Javadoc)
     * @see com.ez.supervise.dao.GoalCategoryDao#getChildrenById(java.lang.Long)
     */
    public List getChildrenById(Long parentId) {
    	Map map = new HashMap();
    	map.put("parentId", parentId);
    	return getSqlMapClientTemplate().queryForList("biz.getChildrenById", map);
    }
	public List<GoalCategory> getChildrenById(Long parentId, Long applyOrgId) {
    	Map map = new HashMap();
    	map.put("parentId", parentId);
    	map.put("applyOrgId", applyOrgId);
		return getSqlMapClientTemplate().queryForList("biz.getChildrenById", map);
	}
    /* (non-Javadoc)
     * @see com.ez.supervise.dao.GoalCategoryDao#getRoots(int)
     */
    public List getRoots(int year) {
	return getSqlMapClientTemplate().queryForList("biz.getRoots", year);
    }

    public GoalCategory getNodeById(Long nodeId) {
	return (GoalCategory) getSqlMapClientTemplate().queryForObject("biz.getNodeById", nodeId);
    }

    public List findValidYear() {
	return getSqlMapClientTemplate().queryForList("biz.findValidYear");
    }

    public int countDetailByCategory(Long categoryId) {
	return (Integer) getSqlMapClientTemplate().queryForObject("biz.countDetailByCategory", categoryId);
    }

    public void updatePercent(Long categoryId) {
	sqlMapClientTemplate.update("biz.updatePercent", categoryId);
    }

	public List findCategoryApply(Map map) {
		return getSqlMapClientTemplate().queryForList("biz.findCategoryApply", map);
	}
}
